package com.fz.consumer.listeners;

import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.core.ExchangeTypes;
import org.springframework.amqp.rabbit.annotation.Exchange;
import org.springframework.amqp.rabbit.annotation.Queue;
import org.springframework.amqp.rabbit.annotation.QueueBinding;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;

@Slf4j
@Component
public class TopicMqListener {
    @RabbitListener(bindings = @QueueBinding(
            value = @Queue(name = "topic.queue1",durable = "true"),
            exchange = @Exchange(name = "test.topic1", type = ExchangeTypes.TOPIC),
            key = {"china.#"}
    ))
    public void topicExChangeListener(String message) {
        log.info("topic交换机的queue1队列收到消息：{}",message);
    }

    @RabbitListener(bindings = @QueueBinding(
            value = @Queue(name = "topic.queue2",durable = "true"),
            exchange = @Exchange(name = "test.topic1", type = ExchangeTypes.TOPIC),
            key = {"#.news"}
    ))
    public void topicExChangeListener2(String message) {
        log.info("topic交换机的queue2队列收到消息：{}",message);
    }
}
